package com.lzy.config;

import com.lzy.controller.interceptor.SMSInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.io.File;

@Configuration
public class StaticResourceConfig implements WebMvcConfigurer {

    /**
     *  添加静态资源映射路径，图片、视频、音频等都存放在classpath下的static中
     */
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {

        /**
         *  addResourceHandler：指的是对外暴露的访问路径映射
         *  addResourceLocations：指的是本地文件的目录
         */
        registry.addResourceHandler("/static/**")
                .addResourceLocations("file:D:/Code/temp/");
        // http://192.168.197.202:55/static/face/1960190049102229507.jpg
    }
}

